#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int m=0;
void hanoi(int n,char a,char b,char c)
{
    if(n==1)  printf("%c->1->%c\n",a,c);
    else
    {
        hanoi(n-1,a,c,b);
        printf("%c->%d->%c\n",a,n,c);
        hanoi(n-1,b,a,c);
    }
}
int main()
{
    char a,b,c;
    cin>>m>>a>>b>>c;
    hanoi(m,a,c,b);
    return 0;
}
